﻿using System;
using System.Collections.Generic;

namespace Infrastructure.WebApi
{
    /// <summary>
    /// 查询条件模型
    /// </summary>
    public partial class Query
    {
        #region Property

        /// <summary>
        /// 查询条件
        /// </summary>
        public string Condition { get; set; }

        /// <summary>
        /// 包含的导航属性
        /// </summary>
        public string Include { get; set; }

        /// <summary>
        /// 排序规则
        /// </summary>
        public string Order { get; set; }

        /// <summary>
        /// 不分页指示，仅对查询请求有效，默认为分页
        /// </summary>
        public bool NotPage { get; set; }

        /// <summary>
        /// 页码
        /// </summary>
        public string CurrentPage { get; set; }

        /// <summary>
        /// 页容量
        /// </summary>
        public string PageSize { get; set; }

        /// <summary>
        /// 指定返回的属性
        /// </summary>
        public string Select { get; set; }

        /// <summary>
        /// 只获取前N条数据
        /// </summary>
        public int TopCount { get; set; }

        /// <summary>
        /// 分组字段
        /// </summary>
        public string GroupBy { get; set; }

        /// <summary>
        /// 分组返回数据
        /// 根据"as"关键字定义求和后的字段名，如果没有指定则以本身字段名作为求和后的字段名
        /// 如:成绩系统根据学生分组求科目数，总分，平均分，最大分，最小分：
        ///     GroupBy设置为"UserId"，此属性设置为"Count(*) As SubjectCount,Sum(Score) As TotalScoe,Avg(Score) As AvgScore,Max(Score) As MaxScore,Min(Score) As MinScore"
        /// 目前支持的聚合操作有：Sum,Avg,Max,Min,Count，不区分大小写
        /// </summary>
        public string GroupSelect { get; set; }

        /// <summary>
        /// 自定义查询参数，用于参数化查询匹配查询条件里的参数
        /// </summary>
        public Dictionary<string, object> Params { get; set; }

        #endregion
    }
}